package com.neymar.mapper;

import com.neymar.entity.Position;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 求职者表 Mapper 接口
 * </p>
 *
 * @author neymar
 * @since 2021-06-02
 */
public interface PositionMapper extends BaseMapper<Position> {

    @Select("<script>"
            + "select a.*,b.* from information.position a join information.recruiter b\n"
            + "where a.publisher_id=b.user_id "
            + "<if test = 'type != null '>"
            + "and a.position_type like '%${type}%'"
            + "</if>"
            + "<if test = 'type != null '>"
            + "and a.position_name like '%${name}%'"
            + "</if>"
            + "limit ${(current-1)*size},${size}"
            + "</script>"
    )
        // https://www.cnblogs.com/unknows/p/13294274.html
    List<Map<String, String>> findAllPositionsDetails(@Param("current") Integer current,
                                                      @Param("size") Integer size,
                                                      @Param("type") String type,
                                                      @Param("name") String name);
}
